package g4p.newg4p;

import java.awt.Font;

import g4p_controls.GButton;
import g4p_controls.GDropList;
import g4p_controls.GEvent;
import processing.core.PApplet;

public class DropList_Test extends PApplet  {

	GDropList fc0, fc1;
	String[] x;
	int dpsize = 5;
	
	Font font24;
	
	GButton[] btnColours = new GButton[8];

	public void setup(){
		size(600,400);
		cursor(CROSS);
		
		font24 = new Font("Dialog", Font.PLAIN, 24);
		
		
		for(int i = 0; i < btnColours.length; i++){
			btnColours[i] = new GButton(this, width - 44, 2 + i * 22, 40, 20, "" + (i+1));
			btnColours[i].tag = "Button: " + (i+1);
			btnColours[i].setLocalColorScheme(i);
			btnColours[i].tagNo = 1000+i;
		}	

		fc0 = new GDropList(this, 20, 86, 200, 24 * (dpsize + 1), dpsize);
		fc0.setFont(font24);
		
		// Set dummy list for testing
		x = new String[] {"Peter Lager", "Donald Duck", "Charlie Brown", "Doctor Who", "Fireman Sam", "Manic Miner", "James Dean", "Mary Whitehouse" };
//		x = new String[] {"Peter Lager", "Donald Duck", "Charlie Brown" , "Doctor Who", "Fireman Sam"};
		fc0.setItems(x,1);

//		fc1 = new GDropList(this, 220, 50, 100, 18 * (dpsize + 1), dpsize);
//		// Set dummy list for testing
//		x = new String[] {"Elephant", "Tiger", "Lion", "Giraffe", "Killer Whale", "Manatee", "Albatross", "Polar Bear" };
////		x = new String[] {"Peter Lager", "Donald Duck", "Charlie Brown" , "Doctor Who", "Fireman Sam"};
//		fc1.setItems(x,1);

//		fc0.setRotation(radians(-2.0f));
	}


	public void draw(){
		background(240);
	}
	
	public void handleDropListEvents(GDropList droplist, GEvent event) {
		System.out.println("Selected " + droplist.getSelectedIndex() + " '" + droplist.getSelectedText() + "'");
	}
	
	public void handleButtonEvents(GButton button, GEvent event) { 
		if(button.tagNo >= 1000)
			fc0.setLocalColorScheme(button.tagNo - 1000, true);
	}
}
